<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <th:block th:include="fragments/header :: header"/>
    <script type="text/javascript" src="../js/jquery.form.js" th:src="@{/js/jquery.form.js}"></script>
</head>
<body>
<div>
<!--    <form action="/markt/player/import" id="excelForm"  method="post" enctype="multipart/form-data">-->
<!--        <input type="file" id="upload" name="file"/>-->
<!--        <button type="submit" id=submit"">提交</button>-->
<!--    </form>-->
    <form action="#" id="excelForm"  method="post" enctype="multipart/form-data">
        <input type="file" id="upload" name="file"/>
<!--        <input id="submit" th:value="提交">-->
        <button id="submit">提交</button>
    </form>
    <script th:inline="javascript">
        /*<![CDATA[*/
        var type = /*[[${typeModel.type}]]*/ "";
        /*]]>*/
    </script>
    <script>
        $(function () {
            $('#submit').click(function(){
                // 设置ajax参数
                var options = {
                    //target: '#output',          //把服务器返回的内容放入id为output的元素中
                    //beforeSubmit: showRequest,  //提交前的回调函数
                    //url: url,                 //默认是form的action， 如果申明，则会覆盖
                    //clearForm: true,          //成功提交后，清除所有表单元素的值
                    //resetForm: true,          //成功提交后，重置所有表单元素的值
                    //timeout: 3000,            //限制请求的时间，当请求大于3秒后，跳出请求
                    // url : '/markt/club/import',
                    url : '/markt/'+type+'/import',
                    type: 'POST',
                    dataType: 'json',
                    async: false,
                    success: function (data) {
                        if (data.success) {
                            // alert('上传成功！');
                            layer.msg("上传成功！");
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        }else {
                            console.log('上传失败');
                        }
                    }
                }
                // 提交表单
                $('#excelForm').ajaxSubmit(options);
            });
        })
    </script>
</div>
</body>
</html>
